const initState = { // 初始值
  num: 0
}

export const addSAction = () => ({
  type: 'ADD'
})
export const decAction = () => ({
  type: 'DEC'
})
export const addNAction = (payload) => ({
  type: 'ADDN',
  payload
})

export default function countReducer(state = initState, action) {
  switch (action.type) {
    case 'ADD':
      return {
        num: state.num + 1
      }
    case 'DEC':
      return {
        num: state.num - 1
      }
    case 'ADDN':
      return {
        num: state.num + action.payload
      }

    default:
      return state;
  }
}